package com.demo.task.core;

import android.app.Activity;
import android.os.Message;

import java.util.HashMap;

/**
 * 作者： andli
 * 时间： 2017/11/7 13:44
 * 描述： Task 抽象类
 */
public abstract class Task {

    public SuperActivity superView;

    public HashMap<String, Object> param;

    public Task(SuperActivity superView, HashMap<String, Object> param) {
        this.superView = superView;
        this.param = param;
        BackService.addTask(this);  // 添加进任务列表
    }

    public abstract void exectue(Message mess) throws Exception;    // 执行接口方法

    /**
     * 通过Message来传递参数给UI
     * 这里封装了2个参数，一个是Context,另一个是HashMap
     *
     * @param mess
     * @param con
     * @param data
     */
    public void setMsg(Message mess, Activity con, Object data) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("con", con);
        map.put("data", data);
        mess.obj = map;
    }


    public Activity getcon() {
        return superView;
    }

    public void setcon(SuperActivity superView) {
        this.superView = superView;
    }

    public HashMap<String, Object> getParam() {
        return param;
    }

    public void setParam(HashMap<String, Object> param) {
        this.param = param;
    }

}